/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.delivery.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Katarina Hrabovska
 */
@Entity
@Table(name = "Delivery")
public class Delivery implements Serializable 
{
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

   
    
    @Enumerated(EnumType.STRING)
    private State state;
    
    @ManyToOne(fetch= FetchType.EAGER)
    @JoinColumn(name="senderId")
    private Contact sender;
    
    @ManyToOne(fetch= FetchType.EAGER)
    @JoinColumn(name="receiverId")
    private Contact receiver;
    
    @Temporal(TemporalType.TIMESTAMP)
    private Date sendingDate;
    
    @Temporal(TemporalType.TIMESTAMP)
    private Date deliveryDate;
    
    @Column(unique=false, nullable=true)
    private String notes;
    
    @Column(unique=false, nullable=false)
    private double price;
    
    @Column
    private boolean paid;
    
   @ManyToOne
    private Employee employee;

   
   @ManyToOne
    private Courier courier;
    
   public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }

    public Contact getSender() {
        return sender;
    }

    public void setSender(Contact sender) {
        this.sender = sender;
    }

    public Contact getReceiver() {
        return receiver;
    }
    
    public void setReceiver(Contact receiver) {
        this.receiver = receiver;
    }

    public Date getSendingDate() {
        return sendingDate;
    }

    public void setSendingDate(Date sendingDate) {
        this.sendingDate = sendingDate;
    }

    public Date getDeliveryDate() {
        return deliveryDate;
    }

    public void setDeliveryDate(Date deliveryDate) {
        this.deliveryDate = deliveryDate;
    }
    
      public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    public Courier getCourier() {
        return courier;
    }

    public void setCourier(Courier courier) {
        this.courier = courier;
    }
    
    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public boolean isPaid() {
        return paid;
    }

    public void setPaid(boolean paid) {
        this.paid = paid;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 29 * hash + (int) (this.id ^ (this.id >>> 32));
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Delivery other = (Delivery) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Delivery{" + "id=" + id + ", state=" + state + ", sender=" + sender + ", receiver=" + receiver + ", sendingDate="
                + sendingDate + ", deliveryDate=" + deliveryDate + ", goods=" + /*goods +*/ ", notes=" + notes + ", price=" + price + 
                ", paid=" + paid + '}';
    }

    
}
